<template>
  <div class="form">
      <div class="form-group">
          <input v-model="brand.name" type="text" placeholder="请填写品牌名称" class="form-control">
      </div>
      <div class="form-group">
          <button @click="add" class="btn btn-primary">新增品牌</button>
      </div>
  </div>
</template>

<script>
import {mapState,mapGetters,mapActions,mapMutations} from 'vuex';
export default {
    data(){
        return {

        }
    },
    computed:{
        ...mapState(['brands','brand']),
        ...mapGetters(['brandsCount'])
    },
    created(){
       
    },
    methods:{
        ...mapActions(['getInitBrands','addBrand','delBrand']),
        ...mapMutations(['getBrands','add','del','update']),
        add(){
            if(!this.brand.name){
                return alert('请填写品牌名称');
            }
            const id=this.brands[0].id+1;
            const brand={id,name:this.brand.name,ctime:parseInt(Date.now()/1000)};
            this.addBrand(brand);
        }
    }
}
</script>

<style>

</style>